package in.cent.server.communication;

import in.cent.common.constants.CommunicationConstants;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

public class Server
{
	private List<Client> clients;

	public Server()
	{
		clients = new ArrayList<Client>();
		ServerSocket sock = null;

		try
		{
			sock = new ServerSocket(CommunicationConstants.PORT);
		} catch (IOException e)
		{
			e.printStackTrace();
			System.exit(-1);
		}

		System.out.println("Accepting clients on PORT" + CommunicationConstants.PORT);

		while (true)
		{
			try
			{
				Socket s = sock.accept();
				clients.add(new Client(s));
			} catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}
}
